def singleton(cls):
    # TODO 实现一个单例装饰器
    _instance = {}

    def inner(*args,**kwargs):
        if cls not in _instance:
            _instance[cls] = cls(*args,**kwargs)
        return _instance[cls]

    return inner


@singleton
class Test:
    pass


test1 = Test()
test2 = Test()


assert test1 is test2, "不是单例"